package com.lemo.smart.thread;

/**
 * Created by 罗选通 on 2017/12/25.
 */
public class SequenceA implements Sequence {

  private MyThreadLocal<Integer> numberContainer = new MyThreadLocal<Integer>() {
    @Override
    protected Integer initialValue() {
      return 0;
    }
  };

  @Override
  public int getNumber() {
    numberContainer.set(numberContainer.get() + 1);
    return numberContainer.get();
  }

  public static void main(String[] args) {
    Sequence sequence = new SequenceA();

    ClientThread clientThread1 = new ClientThread(sequence);
    ClientThread clientThread2 = new ClientThread(sequence);
    ClientThread clientThread3 = new ClientThread(sequence);

    clientThread1.start();
    clientThread2.start();
    clientThread3.start();


  }
}
